-
Notifications
You must be signed in to change notification settings - Fork 6
/
README
41 lines (28 loc) · 1.24 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Hashtable-based-In-Memory-Cache
===============================
Intro:
-----
A simple In-Memory KeyValue store that can be instantiated from with-in any Java program.
Comes with a 'Cleanup thread' that periodically cleans up the Hashtable (based on the TTL for each entry) using
an index (instance of TreeMap collection which is implemented using Red Black tree algorithm)
API methods:
-----------
1. Add (String key, Object value, long TTL) -
a. Accepts KeyValue pair along with Time To Live (TTL).
2. Get (String key) -
a. Returns an Object associated with this key
b. Removes it if expired and throws an exception, "Object expired."
c. If such a key doesn't exist throws an exception, "Object does not exit/expired."
3. Delete (String key) -
a. Deletes a record with the given key if it exists and not already expired. Throws an exception otherwise.
Improvements:
------------
1. The frequency of the cleaner needs to be tuned/improved a lot as per the system's needs/capacity
TestCases:
---------
CacheSystemTestCase3 -
A multi threaded access to the cache. 500 threads calls "add ()" with distict Key-Value pairs, but "get ()"
with random Keys. i.e,. Concurrent reads and no concurrent writes.
Disclaimer:
----------
* Not tested in large scale