static-variables

Is it OK to use static variables to cache information in ASP.net?

北战南征 提交于 2019-11-30 04:41:49
At the moment I am working on a project admin application in C# 3.5 on ASP.net. In order to reduce hits to the database, I'm caching a lot of information using static variables. For example, a list of users is kept in memory in a static class. The class reads in all the information from the database on startup, and will update the database whenever changes are made, but it never needs to read from the datebase. The class pings other webservers (if they exist) with updated information at the same time as a write to the database. The pinging mechanism is a Windows service to which the cache

Static class members python

﹥>﹥吖頭↗ 提交于 2019-11-30 01:41:09
问题 So I'm using static class members so I can share data between class methods and static methods of the same class (there will only be 1 instantiation of the class). I understand this fine, but I'm just wondering when the static members get initialized? Is it on import? On the first use of the class? Because I'm going to be calling the static members of this class from more than 1 module (therefore more than 1 import statement). Will all the modules accessing the static methods share the same

Initialising a static variable in Objective-C category

妖精的绣舞 提交于 2019-11-29 21:08:27
I was trying to create a static variable to store a dictionary of images. Unfortunately, the best way I could find to initialise it was to check in each function that used the variable. Since I am creating this variable inside a category, I can't just initialise it inside the initialiser. Is there a neater way of initialising navigationBarImages? static NSMutableDictionary *navigationBarImages = NULL; @implementation UINavigationBar(CustomImage) //Overrider to draw a custom image - (void)drawRect:(CGRect)rect { if(navigationBarImages==NULL){ navigationBarImages=[[NSMutableDictionary alloc]

BroadcastReceiver Life Cycle — Static Variables

半世苍凉 提交于 2019-11-29 19:37:55
问题 I have a BroadcastReceiver class. I have some static variables declared whose value is updated in side the onReceive() method. As per my knowledge static variable will keep it's value across the onReceive calls. Is there any possibility when I will loose those values(Like my class will be unloaded resetting the static variables)? These are basically some temporary variables I need to be available for multiple onReceive calls. 回答1: From the documentation for BroadcastReceiver Lifecycle... A

static variable initialisation code never gets called

风流意气都作罢 提交于 2019-11-29 16:28:35
I've got an application that's using a static library I made. One .cpp file in the library has a static variable declaration, whose ctor calls a function on a singleton that does something- e.g. adds a string. Now when I use that library from the application, my singleton doesn't seem to contain any traces of the string that was supposed to be added. I'm definitely missing something but I don't know what.. If you have an object in a static library that is not EXPLICITLY used in the application. Then the linker will not pull that object from the lib into the application. There is a big

Is a static variable in a library (DLL) shared by all processes referencing that library?

旧时模样 提交于 2019-11-29 05:57:06
问题 I know that a static variable used in a web application is shared for all users across the web application. If I have a library (DLL) that uses some static private variable, do all applications using that library share the value of that variable? For example, say I have the following code in my DLL: private static bool isConnected = false; public static void Connect() { // TODO: Connect. isConnected = true; } public static void Disconnect() { // TODO: Disconnect. isConnected = false; } Then

Is it OK to use static variables to cache information in ASP.net?

你。 提交于 2019-11-29 02:00:43
问题 At the moment I am working on a project admin application in C# 3.5 on ASP.net. In order to reduce hits to the database, I'm caching a lot of information using static variables. For example, a list of users is kept in memory in a static class. The class reads in all the information from the database on startup, and will update the database whenever changes are made, but it never needs to read from the datebase. The class pings other webservers (if they exist) with updated information at the

What is the difference between .LIB and .OBJ files? (Visual Studio C++)

此生再无相见时 提交于 2019-11-28 22:49:15
I know .OBJ is the result of compiling a unit of compilation and .LIB is a static library that can be created from several .OBJ, but this difference seems to be only in the number of units of compilation. Is there any other difference? Is it the same or different file format? I have come to this question when wondering if the same static variable defined in two (or more) .LIBs is merged or not during linking into the final executable. For .OBJs the variables are merged. But is it the same in .LIBs? A .LIB file is a collection of .OBJ files concatenated together with an index. There should be

Initialising a static variable in Objective-C category

ぐ巨炮叔叔 提交于 2019-11-28 17:15:10
问题 I was trying to create a static variable to store a dictionary of images. Unfortunately, the best way I could find to initialise it was to check in each function that used the variable. Since I am creating this variable inside a category, I can't just initialise it inside the initialiser. Is there a neater way of initialising navigationBarImages? static NSMutableDictionary *navigationBarImages = NULL; @implementation UINavigationBar(CustomImage) //Overrider to draw a custom image - (void

Can I have different copies of a static variable for each different type of inheriting class

我与影子孤独终老i 提交于 2019-11-28 11:26:55
I want to have the same static variable with a different value depending on the type of class. So I would have public class Entity { public static Bitmap sprite; public void draw(Canvas canvas, int x, int y) { canvas.drawBitmap(sprite, x, y, null); } } public class Marine extends Entity { } public class Genestealer extends Entity { } And then in my main program go: Marine.sprite = // Load sprite for all instances of Marine Genestealer.sprite = // Load sprite for all instances of Genestealer I don't want to store the same sprite in every instance of the class. I want one for each type of class.