View Source nitro_cache (nitro_cache v0.5.0)

Main module for nitro_cache.

Copyright 2013 Marcelo Gornstein <marcelog@gmail.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Summary

Functions

Deletes all keys in the given cache.
Deletes the keys that match the given ets:matchspec() from the cache.
Deletes a key from cache only if it still has the expected Expiry value. This is used by the expirer when a key is due to expire. This avoids inadvertently deleting a value that has since been updated (it would thus have a different Expiry).
Tries to lookup Key in the cache, and execute the given FunResult on a miss.
Initializes a cache.
Sets Key in the cache to the given Value

Functions

-spec cache_exists(atom()) -> boolean().
-spec flush(atom()) -> true.
Deletes all keys in the given cache.
-spec flush(atom(), term()) -> true.
Deletes the keys that match the given ets:matchspec() from the cache.
Link to this function

flush(CacheName, Key, Expiry)

View Source
-spec flush(atom(), term(), pos_integer()) -> true.
Deletes a key from cache only if it still has the expected Expiry value. This is used by the expirer when a key is due to expire. This avoids inadvertently deleting a value that has since been updated (it would thus have a different Expiry).
Link to this function

get(CacheName, LifeTime, Key, FunResult)

View Source
-spec get(atom(), infinity | integer(), term(), function()) -> term().
Link to this function

get_only(CacheName, Key)

View Source
-spec get_only(atom(), term()) -> undefined | term().
Tries to lookup Key in the cache, and execute the given FunResult on a miss.
-spec init(atom()) -> ok.
Initializes a cache.
Link to this function

set(CacheName, LifeTime, Key, Value)

View Source
-spec set(atom(), infinity | pos_integer(), term(), term()) -> ok.
Sets Key in the cache to the given Value