File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Java SimpleCache
2
+
3
+ The Java SimpleCache Class is an easy way to cache 3rd party API calls.
4
+
5
+ ## Usage
6
+
7
+ A very basic usage example:
8
+
9
+ ``` java
10
+ SimpleCache cache = new SimpleCache ();
11
+ String data = cache. get_data(' label' , ' http://some.api.com/file.json' );
12
+ System . out. println(data);
13
+ ```
14
+
15
+ A more advanced example:
16
+
17
+ ``` java
18
+ SimpleCache cache = new SimpleCache ();
19
+ cache. set_cache_time(3 );
20
+ cache. set_cache_path(" cache/" );
21
+ cache. set_cache_extension(" .json" );
22
+
23
+ String data = null ;
24
+
25
+ if (cache. get_cache(" label" ) != null ) {
26
+ data = cache. get_cache(" label" );
27
+ } else {
28
+ data = cache. grab_url(" http://some.api.com/file.json" );
29
+ cache. set_cache(" label" , data);
30
+ }
31
+
32
+ System . out. println(data);
33
+ ```
34
+
35
+ ## Credits
36
+
37
+ SimpleCache Caching Class Originally published in PHP by [ Gilbert Pellegrom] ( https://github.com/gilbitron/PHP-SimpleCache ) . Ported to Java by me :)
You can’t perform that action at this time.
0 commit comments