Page Speed Optimization Libraries
1.6.29.3
|
#include "async_cache.h"
Public Member Functions | |
AsyncCache (CacheInterface *cache, QueuedWorkerPool *pool) | |
virtual void | Get (const GoogleString &key, Callback *callback) |
virtual void | Put (const GoogleString &key, SharedString *value) |
virtual void | Delete (const GoogleString &key) |
virtual void | MultiGet (MultiGetRequest *request) |
virtual GoogleString | Name () const |
virtual bool | IsBlocking () const |
virtual void | ShutDown () |
void | CancelPendingOperations () |
virtual bool | IsHealthy () const |
int32 | outstanding_operations () |
Static Public Member Functions | |
static GoogleString | FormatName (StringPiece cache) |
Static Public Attributes | |
static const int64 | kMaxQueueSize = 2000 |
Employs a QueuedWorkerPool to turn a synchronous cache implementation into an asynchronous one. This makes sense to do only if the cache implemention is potentially slow, due to network latency or disk seek time.
This class also serves to serialize access to the passed-in cache, ensuring that it is accessed from only one thread at a time.
net_instaweb::AsyncCache::AsyncCache | ( | CacheInterface * | cache, |
QueuedWorkerPool * | pool | ||
) |
Does not takes ownership of the synchronous cache that is passed in. Does not take ownership of the pool, which might be shared with other users.
Note that in the future we may try to add multi-threaded access to the underlying cache (e.g. AprMemCache supports this), so we take the pool as the constructor arg.
void net_instaweb::AsyncCache::CancelPendingOperations | ( | ) | [inline] |
Cancels all pending cache operations. Puts and Deletes are dropped. Gets and MultiGets are retired by calling their callbacks with kNotFound.
virtual void net_instaweb::AsyncCache::ShutDown | ( | ) | [virtual] |
Prevent the AsyncCache from issuing any more Gets. Any subsequent Gets will have their callback invoked immediately with kNotFound. Outstanding Gets may be completed depending on timing.
This can be called during the process Shutdown flow to avoid introducing more work asynchronously that will have to be completed prior to Shutdown.
const int64 net_instaweb::AsyncCache::kMaxQueueSize = 2000 [static] |
The maximum number of operations that can be queued up while a server is slow. When this is reached, old Deletes/Puts get dropped, and old Gets are retired with a kNotFound.
This helps bound the amount of memory consumed by queued operations when the cache gets wedged. Note that when CacheBatcher is layered above AsyncCache, it will queue up its Gets at a level above this one, and ultimately send those using a MultiGet.