A
Anders Borum
Hello!
I am developing an API that supports caching and would like your comments on
my implementation (and thoughts on the subject).
A set of Service classes have been designed, allowing the programmer to
access the functionality in the API. A Service could for instance allow the
programmering to retrieve Pages, Users or Modules (these are objects that
are cached in the API using their Guid as indexing key).
Each Service class inherits from a base CacheService class, which in turn
creates an internal cache (a synchronized Hashtable). For instance:
public class PageService : CacheService {}
Each Service is accessed from a Context object that exposes the different
Services. For instance:
Page page = Context.PageService.GetPage(..);
I am thinking about making a single cache available across all the Service
classes, instead of having them create their own instance internally. The
idea is to host the cache in the Context object, then making it available to
the Service classes.
The idea of having a single cache is interesting, as it allows for
monitoring, a single point of flushing and so on. However, I am a bit
worried that the synchronization on the Cache would slow things down -
compared to the distributed version, where each Service only locks its own
ressources when accessing the synchronized Cache.
Ideas and thoughts are greatly appreciated!
I am developing an API that supports caching and would like your comments on
my implementation (and thoughts on the subject).
A set of Service classes have been designed, allowing the programmer to
access the functionality in the API. A Service could for instance allow the
programmering to retrieve Pages, Users or Modules (these are objects that
are cached in the API using their Guid as indexing key).
Each Service class inherits from a base CacheService class, which in turn
creates an internal cache (a synchronized Hashtable). For instance:
public class PageService : CacheService {}
Each Service is accessed from a Context object that exposes the different
Services. For instance:
Page page = Context.PageService.GetPage(..);
I am thinking about making a single cache available across all the Service
classes, instead of having them create their own instance internally. The
idea is to host the cache in the Context object, then making it available to
the Service classes.
The idea of having a single cache is interesting, as it allows for
monitoring, a single point of flushing and so on. However, I am a bit
worried that the synchronization on the Cache would slow things down -
compared to the distributed version, where each Service only locks its own
ressources when accessing the synchronized Cache.
Ideas and thoughts are greatly appreciated!