leveldb
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
leveldb::CacheTest Class Reference
Collaboration diagram for leveldb::CacheTest:
Collaboration graph
[legend]

Public Member Functions

 CacheTest ()
 
 ~CacheTest ()
 
int Lookup (int key)
 
void Insert (int key, int value, int charge=1)
 
Cache::HandleInsertAndReturnHandle (int key, int value, int charge=1)
 
void Erase (int key)
 

Static Public Member Functions

static void Deleter (const Slice &key, void *v)
 

Public Attributes

std::vector< int > deleted_keys_
 
std::vector< int > deleted_values_
 
Cachecache_
 

Static Public Attributes

static CacheTestcurrent_
 
static const int kCacheSize = 1000
 

Detailed Description

Definition at line 26 of file cache_test.cc.

Constructor & Destructor Documentation

§ CacheTest()

leveldb::CacheTest::CacheTest ( )
inline

Definition at line 40 of file cache_test.cc.

41  current_ = this;
42  }
static CacheTest * current_
Definition: cache_test.cc:28
Cache * NewLRUCache(size_t capacity)
Definition: cache.cc:401
static const int kCacheSize
Definition: cache_test.cc:35

§ ~CacheTest()

leveldb::CacheTest::~CacheTest ( )
inline

Definition at line 44 of file cache_test.cc.

44  {
45  delete cache_;
46  }

Member Function Documentation

§ Deleter()

static void leveldb::CacheTest::Deleter ( const Slice key,
void *  v 
)
inlinestatic

Definition at line 30 of file cache_test.cc.

30  {
31  current_->deleted_keys_.push_back(DecodeKey(key));
32  current_->deleted_values_.push_back(DecodeValue(v));
33  }
static int DecodeKey(const Slice &k)
Definition: cache_test.cc:19
static int DecodeValue(void *v)
Definition: cache_test.cc:24
std::vector< int > deleted_values_
Definition: cache_test.cc:37
static CacheTest * current_
Definition: cache_test.cc:28
std::vector< int > deleted_keys_
Definition: cache_test.cc:36
Here is the call graph for this function:
Here is the caller graph for this function:

§ Erase()

void leveldb::CacheTest::Erase ( int  key)
inline

Definition at line 67 of file cache_test.cc.

67  {
68  cache_->Erase(EncodeKey(key));
69  }
static const char * EncodeKey(std::string *scratch, const Slice &target)
Definition: memtable.cc:44
virtual void Erase(const Slice &key)=0
Here is the call graph for this function:
Here is the caller graph for this function:

§ Insert()

void leveldb::CacheTest::Insert ( int  key,
int  value,
int  charge = 1 
)
inline

Definition at line 57 of file cache_test.cc.

57  {
58  cache_->Release(cache_->Insert(EncodeKey(key), EncodeValue(value), charge,
60  }
virtual Handle * Insert(const Slice &key, void *value, size_t charge, void(*deleter)(const Slice &key, void *value))=0
static void Deleter(const Slice &key, void *v)
Definition: cache_test.cc:30
virtual void Release(Handle *handle)=0
static const char * EncodeKey(std::string *scratch, const Slice &target)
Definition: memtable.cc:44
static void * EncodeValue(uintptr_t v)
Definition: cache_test.cc:23
Here is the call graph for this function:
Here is the caller graph for this function:

§ InsertAndReturnHandle()

Cache::Handle* leveldb::CacheTest::InsertAndReturnHandle ( int  key,
int  value,
int  charge = 1 
)
inline

Definition at line 62 of file cache_test.cc.

62  {
63  return cache_->Insert(EncodeKey(key), EncodeValue(value), charge,
65  }
virtual Handle * Insert(const Slice &key, void *value, size_t charge, void(*deleter)(const Slice &key, void *value))=0
static void Deleter(const Slice &key, void *v)
Definition: cache_test.cc:30
static const char * EncodeKey(std::string *scratch, const Slice &target)
Definition: memtable.cc:44
static void * EncodeValue(uintptr_t v)
Definition: cache_test.cc:23
Here is the call graph for this function:
Here is the caller graph for this function:

§ Lookup()

int leveldb::CacheTest::Lookup ( int  key)
inline

Definition at line 48 of file cache_test.cc.

48  {
49  Cache::Handle* handle = cache_->Lookup(EncodeKey(key));
50  const int r = (handle == NULL) ? -1 : DecodeValue(cache_->Value(handle));
51  if (handle != NULL) {
52  cache_->Release(handle);
53  }
54  return r;
55  }
virtual void Release(Handle *handle)=0
virtual void * Value(Handle *handle)=0
static const char * EncodeKey(std::string *scratch, const Slice &target)
Definition: memtable.cc:44
static int DecodeValue(void *v)
Definition: cache_test.cc:24
virtual Handle * Lookup(const Slice &key)=0
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

§ cache_

Cache* leveldb::CacheTest::cache_

Definition at line 38 of file cache_test.cc.

§ current_

CacheTest * leveldb::CacheTest::current_
static

Definition at line 28 of file cache_test.cc.

§ deleted_keys_

std::vector<int> leveldb::CacheTest::deleted_keys_

Definition at line 36 of file cache_test.cc.

§ deleted_values_

std::vector<int> leveldb::CacheTest::deleted_values_

Definition at line 37 of file cache_test.cc.

§ kCacheSize

const int leveldb::CacheTest::kCacheSize = 1000
static

Definition at line 35 of file cache_test.cc.


The documentation for this class was generated from the following file: