RestAuth v2.0.0 RestAuth.CacheService View Source
Generic caching service to be used by the user implemented handler module.
Most functions from the handler should use the cache service for best performance and behaviour.
The data is cached in ETS tables. The service expects a homogeneous
node setup where each node has a process called Elixir.RestAuth.CacheService
that can be
used for communication. All writes are dispatched through all the nodes using
GenServer.multi_call/4
, while reads are dirty from the local ETS table.
Using this cache without nodes being connected will leave you unable to
invalidate acl or kill off user sessions.
The name of the server can be customized using the :cache_service_name
application environment configuration.
Link to this section Summary
Functions
Looks up in the cache if a user can access an item in the system
Returns a specification to start this module under a supervisor
Clears all the caches
Looks up a user in the cache based on the authority
Invalidates an authority based on the set user_id
and token
Invalidates all authorities for a given user_id
Invalidates all access records for a given user_id
in a RestAuth.Authority
Synchronously puts a user in the cache
Sets user access for a user_id
, category
and target_id
in the caching layer
Link to this section Types
Link to this section Functions
can_user_access?(RestAuth.Authority.t, category, target_id) :: :not_found | boolean
Looks up in the cache if a user can access an item in the system.
Returns a boolean or :not_found
if no information is found in the cache.
Returns a specification to start this module under a supervisor.
See Supervisor
.
Clears all the caches.
On success returns the count of nodes written to, on failure the list of nodes with failed writes.
get_user(RestAuth.Authority.t) :: :not_found | {:ok, RestAuth.Authority.t}
Looks up a user in the cache based on the authority.
Requires :user_id
and :token
fields to be set in the authority struct.
invalidate_token(RestAuth.Authority.t) :: {:ok, non_neg_integer} | {:error, [Node.t]}
Invalidates an authority based on the set user_id
and token
.
On success returns the count of nodes written to, on failure the list of nodes with failed writes.
invalidate_user(RestAuth.Authority.t) :: {:ok, non_neg_integer} | {:error, [Node.t]}
Invalidates all authorities for a given user_id
.
On success returns the count of nodes written to, on failure the list of nodes with failed writes.
invalidate_user_access(RestAuth.Authority.t) :: {:ok, non_neg_integer} | {:error, [Node.t]}
Invalidates all access records for a given user_id
in a RestAuth.Authority
.
On success returns the count of nodes written to, on failure the list of nodes with failed writes.
put_user(RestAuth.Authority.t) :: {:ok, non_neg_integer} | {:error, [Node.t]}
Synchronously puts a user in the cache.
The call is synchronous to limit concurrent updates from multiple nodes.
On success returns the count of nodes written to, on failure the list of nodes with failed writes.
put_user_access(RestAuth.Authority.t, category, target_id, boolean) :: {:ok, non_neg_integer} | {:error, [Node.t]}
Sets user access for a user_id
, category
and target_id
in the caching layer.
On success returns the count of nodes written to, on failure the list of nodes with failed writes.