https://github.com/joscha/play-temporary-storage
Temporary storage module for the Play Framework 2
https://github.com/joscha/play-temporary-storage
Last synced: 10 months ago
JSON representation
Temporary storage module for the Play Framework 2
- Host: GitHub
- URL: https://github.com/joscha/play-temporary-storage
- Owner: joscha
- Created: 2014-03-22T14:16:13.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2014-03-22T16:20:06.000Z (almost 12 years ago)
- Last Synced: 2025-01-25T21:10:00.368Z (12 months ago)
- Language: Java
- Size: 191 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
play-temporary-storage [](https://travis-ci.org/joscha/play-temporary-storage)
======================
Temporary storage module for the Play Framework 2 that allows to put serializable objects into
* the Play cache
* the Play session
* with optional AES encryption
and set an expiration time.
The interface of `TemporaryStorage` is 100% compatible to the one of [`play.Cache`](http://www.playframework.com/documentation/2.0/JavaCache).
Have a look at the simple interface [here](code/app/com/feth/play/module/ts/TemporaryStorage.java) and don't forget to check out the [sample application](sample/).
## Sample
```java
final boolean encrypted = true;
// use the session to store our data and enable encryption
final TemporaryStorage storage = new SessionTemporaryStorage(session(), encrypted);
// fetch the count
Integer count = storage.get("count");
// set the count - it will expire in 5 seconds
storage.set("count", count == null ? count = 0 : ++count, 5);
if(count > 3) {
// remove the count
storage.remove("count");
}
```