177 replies
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
Using DataGrid was wonderful but postback for sorting and paging was ugly, it really jeopardise pace and user-friendliness of your website.... also, maintaining Parent-Child relationship in datagrid required too much efforts..... but not any more.... GRIDVIEW and DETAILSWIEW are two new data bound controls, being shipped with ASP.NET 2.0. While GRIDVIEW is a next generation sequel to DataGrid with lot of enhancements like no postback for paging, sorting etc., DETAILSWIEW is all new control with that enables you to work with individual database records. You can use the DETAILSWIEW control on its own, to display or edit a single database record. When used in conjunction with the GRIDVIEW control, you can use the DETAILSWIEW control to quickly build master/detail forms.
Wanna know more about these two..???
read this aricle.
by ali.ikhan
Before I noticed, almost half of 2005 has already gone!!! and here is time to review new products, breakthroughs, applications that we saw since the dawn of 2005. Well, I found this wonderful article which gives epitome of best applications in numerous areas like Development Tools, Data Editing & Reporting, Bug Tracking, Media & Charting etc.
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Name says it all.... Yeah! yet another ASP.NET 2.0 control caught my attention today.... sometimes tree control displays data better than none and thats the reason we have them so many in our desktop applications.... so why leave web applications......
Seems thats what guyz at Microsoft thought... and the result is this excellent tree control.... you can bind it with data by simple xml file.... thats really fantastic...
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
Aright, you are developing a web application, huge amount of data is fetched for being displayed, heavy loaded database fetch calls are involved, you knew queries to database are same everytime (like front page of any portal) but you don?t know how to exploit this fact OR even if you knew caching can make your application flashing fast but who in the world will develop cache for you...??? Well, the single solution for this fiasco is Microsoft?s Caching Block and yes, Microsoft did this for you and that too, free of cost so blaming & bashing Microsoft for every bad thing is not a good thing to do. Okay, now let get into bit detail about caching block....
Microsoft Application Block is a suite of open source, free applications of which Caching block is a part. Other constituents of block are Data block, Exception Management block etc. Caching block gives you power to add a cache to your application and later store/retrieve from it. Its based on LRU policy and it can store any thing in the world in it (as it basically implemented for object). Sooooo enough of intro, lets jump into it.
For any application to use cache block, you need to give some configuration information to block. You can provide this in App.config (for desktop application) or web.config (in case of web application). What this configuration info. will be...? just copy-paste this code...
type="Microsoft.ApplicationBlocks.Cache.CacheConfigurationHandler ,Microsoft.ApplicationBlocks.Cache" />
AssemblyName="Microsoft.ApplicationBlocks.Cache"
ClassName="Microsoft.ApplicationBlocks.Cache.DataProtection.Defau ltDataProtection"
ValidationKey="Oci44OQ9C3xAdQ3/BMHpksPfzeTezLkXen/ahQ8T7nVk/KMgAF nssQJr00KUNhRso+MpLVwAinGep6i14X9M+A=="
Validation="SHA1"/>
ClassName="Microsoft.ApplicationBlocks.Cache.Storages.SingletonCa cheStorage" Mode="InProc" Validated="true" Encrypted="true" RemotingUrl="tcp://localhost:8282/CacheService" />
ClassName="Microsoft.ApplicationBlocks.Cache.Scavenging.LruScaven ging" MemoryPollingPeriod="60" UtilizationForScavenging="80" MaximumSize="5"/>
Now, how to use cache.
Add the following line at top of your class.
using Microsoft.ApplicationBlocks.Cache;
Next, add any object in cache...
CacheManager.GetCacheManager().Add(rstrKey, roData);
where rstrKey is key to the stored data, which you will later use to fetch data back from cache and roData is the data, it can be of any type, ranging from string, int, bool... other primitive types to your custom class objects, as in actuality, everything is derived from object class and above function expects any object?s object to arrive as parameter.
Now what about retrieval of data, well, its also as simple as;
String strMyData = (string) CacheManager.GetCacheManager().GetData(rstrKey);
where rstrKey is again key to data, and supposing our stored data was actually of string type we got data from cache, casted it in string and wow!! here we have our data back.
If for some reason, you need to remove data from cache (data being invalid due to update in database) use this code.
CacheManager.GetCacheManager().Remove(rstrKey);
So how is it...? wonderful.... yeah I knew and that?s why I shared this with you.... now do try it.....
Happy coding...... :)
by ali.ikhan
A very hot question you usually encounter in job interviews and university viva is ?Are there pointers in C#? if so, then how to use them?? and its very disgusting to see 90% people failing to answer.... so here I?ll show you today how easy it is to use pointers in C#. The key of usage is.... the unsafe keyword. Whenever and wherever you?ll use it, compiler will know unsafe code is going to follow and obviously pointers are such piece of code....
See this sample below....
using System;
class Dummy
{
static void Main()
{
PlayWithPointers();
}
unsafe static void PlayWithPointers()
{
int *p;
int i;
i = 70;
p = &i;
string addr;
addr = int.Format((int) p, "X");
//To Format the Pointer to a String
Console.WriteLine(addr);
Console.WriteLine(*p);
*p = 333;
Console.WriteLine(i);
//Change the Value using Pointer
i = *(&i) + 10;
Console.WriteLine(i);
}
}
I think anyone having prior experience of playing with pointers in C/C++ will take above code as piece of cake..... really easy and strikingly similar to pointers in C/C++. The only difference is, as I notified earlier, is unsafe keyword.
So, now have fun with pointers in C# as well..... and oh yes, I knew you have got a point in favor of C# in ?C# vs. java? debate here.......
Have a nice day......
Trending After Hours posts
Sort by Trending