cache-bucket

Light weight in-memory cache bucket

License

License

GroupId

GroupId

com.github.sats17
ArtifactId

ArtifactId

cache-bucket
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

cache-bucket
Light weight in-memory cache bucket
Project URL

Project URL

https://github.com/sats17/cache-bucket
Source Code Management

Source Code Management

https://github.com/sats17/cache-bucket/

Download cache-bucket

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.sats17/cache-bucket/ -->
<dependency>
    <groupId>com.github.sats17</groupId>
    <artifactId>cache-bucket</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.sats17/cache-bucket/
implementation 'com.github.sats17:cache-bucket:1.0.0'
// https://jarcasting.com/artifacts/com.github.sats17/cache-bucket/
implementation ("com.github.sats17:cache-bucket:1.0.0")
'com.github.sats17:cache-bucket:jar:1.0.0'
<dependency org="com.github.sats17" name="cache-bucket" rev="1.0.0">
  <artifact name="cache-bucket" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.sats17', module='cache-bucket', version='1.0.0')
)
libraryDependencies += "com.github.sats17" % "cache-bucket" % "1.0.0"
[com.github.sats17/cache-bucket "1.0.0"]

Dependencies

compile (1)

Group / Artifact Type Version
org.jsmart : zerocode-tdd-jupiter jar 1.3.27

Project Modules

There are no modules declared in this project.

Actions Status Coverage Quality Gate Status License

Cache-Bucket

In memory cache bucket, used to store server side cache

Versions

cache-bucket
1.0.0

Maven Dependency

<dependency>
  <groupId>com.github.sats17</groupId>
  <artifactId>cache-bucket</artifactId>
  <version>1.0.0</version>
</dependency>

Required Imports

import com.github.sats17.cache.extern.CacheBucket;
import com.github.sats17.cache.internal.services.BucketController;

Initialize bucket with size

int size = 100;
CacheBucket bucket = new BucketController(size);

Initialize bucket with size and TTL

int size = 100;
long ttl = 60000; // 60 seconds
CacheBucket bucket = new BucketController(size, ttl);

Set cache

String key = "cacheKey";
Object value = new Object();
bucket.setCache(key, value);

Retrieve cache by key

Object value = bucket.getCache(key); 
note : By default get cache method returns cache value type as Object, You need to explicitly cast the value according to your use
CacheBucket bucket = new BucketController(10,100000);
bucket.setCache("key", "cacheValue");
String value = (String) bucket.getCache("test");

Retrieve all cache from bucket

Map<String, Object> values = bucket.getAll();

Clear cache by key

bucket.clear(key);

Clear all cache from bucket

bucket.clear();

Demo project

https://github.com/sats17/cache-bucket-demo

Versions

Version
1.0.0