Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/spaceeec/crux_cache
A library providing a cache for Discord API structures
https://github.com/spaceeec/crux_cache
cache discord discord-api elixir library
Last synced: about 1 month ago
JSON representation
A library providing a cache for Discord API structures
- Host: GitHub
- URL: https://github.com/spaceeec/crux_cache
- Owner: SpaceEEC
- License: mit
- Created: 2018-04-25T17:25:37.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-25T13:45:40.000Z (over 5 years ago)
- Last Synced: 2024-05-12T10:51:11.436Z (9 months ago)
- Topics: cache, discord, discord-api, elixir, library
- Language: Elixir
- Homepage:
- Size: 54.7 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Crux.Cache
Library providing Discord API struct caches for crux.
## Useful links
- [Documentation](https://hexdocs.pm/crux_cache/0.2.0/)
- [Github](https://github.com/SpaceEEC/crux_cache/)
- [Changelog](https://github.com/SpaceEEC/crux_cache/releases/tag/0.2.0/)
- [Umbrella Development Documentation](https://crux.randomly.space/)## Installation
The library can be installed by adding `crux_cache` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:crux_cache, "~> 0.2.0"}
]
end
```## Usage
Small example:
```elixir
# Should be part of supervision tree
iex> {:ok, pid} = Crux.Cache.Default.start_link()
{:ok, #PID<0.178.0>}iex(2)> Crux.Cache.User.insert(%{
...(2)> "avatar" => "646a356e237350bf8b8dfde15667dfc4",
...(2)> "discriminator" => "0001",
...(2)> "id" => "218348062828003328",
...(2)> "username" => "space"
...(2)> }
...(2)> )
%{
avatar: "646a356e237350bf8b8dfde15667dfc4",
discriminator: "0001",
id: 218348062828003328,
username: "space"
}iex(3)> Crux.Cache.User.fetch!(218348062828003328)
%Crux.Structs.User{
avatar: "646a356e237350bf8b8dfde15667dfc4",
bot: false,
discriminator: "0001",
id: 218348062828003328,
username: "space"
}
```