|
1 | | -# Mnemosyne |
| 1 | +# Athena |
2 | 2 |
|
3 | | -Mnemosyne is a multilayer cache which can be configured to use various configurations of [Redis](https://redis.io/) and/or [BigCahce](https://github.com/allegro/bigcache) (an in-memory caching package) with minimum configuration out of the box. |
| 3 | +Athena is a A/B test library which make running simoultinious tests easy. |
4 | 4 |
|
5 | 5 | ## Getting Started |
6 | 6 |
|
7 | 7 | ### Installing |
8 | 8 |
|
9 | 9 | ```console |
10 | | -go get -u github.com/cafebazaar/mnemosyne |
| 10 | +go get -u git.cafebazaar.ir/bazaar/common/athena |
11 | 11 | ``` |
12 | 12 |
|
13 | 13 |
|
14 | | -### Initializing a Manager and Selecting a Cache Instance |
| 14 | +### Initializing an instance |
15 | 15 |
|
16 | 16 | ```go |
17 | | -mnemosyneManager := mnemosyne.NewMnemosyne(config, nil, nil) |
18 | | -cacheInstance := mnemosyneManager.select("result-cache") |
| 17 | +athenaInstance := athena.NewAthena(config, nil) |
19 | 18 | ``` |
20 | 19 |
|
21 | | -### Working with a cacheInstance |
| 20 | +### Working with test groups |
22 | 21 | ```go |
23 | | - cacheInstance.Set(context, key, value) |
24 | | - var myCachedData myType |
25 | | - err := cacheInstance.Get(context, key, &myCachedData) |
26 | | - // cache miss is also an Error |
| 22 | + athenaInstance.GetTestVariants("123") |
27 | 23 | ``` |
28 | 24 |
|
29 | 25 | ## Configuration |
30 | 26 |
|
31 | | -Mnemosyne uses Viper as it's config engine. Template of each cache instance includes the list of the layers' names (in order of precedence) followed by configuration for each layer. |
| 27 | +Athena uses Viper as it's config engine. Template of each cache instance includes the list of the testGroups' names followed by variants and other configurations for each test group. |
32 | 28 | here's an example: |
33 | 29 | ```yaml |
34 | | -cache: |
35 | | - my-result-cache: # arbitary name for the cache instance |
36 | | - soft-ttl: 2h |
37 | | - layers: # Arbitary names for each cache layer |
38 | | - - result-memory |
39 | | - - result-gaurdian |
40 | | - result-memory: |
41 | | - type: memory |
42 | | - max-memory: 512 |
43 | | - ttl: 2h |
44 | | - amnesia: 10 |
45 | | - compression: true |
46 | | - result-gaurdian: |
47 | | - type: gaurdian |
48 | | - address: "localhost:6379" |
49 | | - slaves: |
50 | | - - "localhost:6380" |
51 | | - - "localhost:6381" |
52 | | - db: 2 |
53 | | - ttl: 24h |
54 | | - amnesia: 0 |
55 | | - compression: true |
56 | | - my-user-cache: |
57 | | - soft-ttl: 2h |
58 | | - layers: |
59 | | - - user-memory |
60 | | - - user-redis |
61 | | - user-memory: |
62 | | - type: memory |
63 | | - max-memory: 512 |
64 | | - ttl: 2h |
65 | | - amnesia: 0 |
66 | | - compression: true |
67 | | - user-redis: |
68 | | - type: redis |
69 | | - address: "localhost:6379" |
70 | | - db: 4 |
71 | | - ttl: 24h |
72 | | - amnesia: 0 |
73 | | - compression: true |
| 30 | +test: |
| 31 | + - name: test1 |
| 32 | + default-variant: o1 |
| 33 | + variants: |
| 34 | + - name: var1 |
| 35 | + percentage: 30 |
| 36 | + - name: var2 |
| 37 | + percentage: 40 |
| 38 | + - name: test2 |
| 39 | + default-variant: o2 |
| 40 | + variants: |
| 41 | + - name: var1 |
| 42 | + percentage: 50 |
| 43 | + - name: var2 |
| 44 | + percentage: 20 |
74 | 45 | ``` |
75 | 46 |
|
76 | | -`soft-ttl` is an instance-wide TTL which when expired will **NOT** remove the data from the instance, but warns that the data is old |
77 | | - |
78 | | -Each cache layer can be of types `redis`, `gaurdian`, `memory` or `tiny`. `redis` is used for a single node Redis server, `gaurdian` is used for a master-slave Redis cluster configuration, `memory` uses the BigCache library to provide an efficient and fast in-memory cache, `tiny` uses the native sync.map data structure to store smaller cache values in memory (used for low-write caches). |
79 | | -Note: all of the cache types are sync-safe, meaning they can be safely used from simultaneously running goroutines. |
80 | | - |
81 | | -#### Common layer configs: |
82 | | - |
83 | | -`amnesia` is a stochastic fall-through mechanism which allows for a higher layer to be updated from a lower layer by the way of an artificial cache-miss, |
84 | | -a 0 amnesia means that the layers will never miss a data that they actually have, a 10 amnesia means when a key is present in the cache, 90% of the time it is returned but 10% of the time it is ignored and is treated as a cache-miss. a 100 amnesia effectively turns the layer off. (Default: 0) |
85 | | - |
86 | | -`compression` is whther the data is compressed before being put into the cache memory. Currently only Zlib compression is supported. (Default: false) |
87 | | - |
88 | | -`ttl` is the hard Time To Live for the data in this particular layer, after which the data is expired and is expected to be removed. |
89 | | - |
90 | | -#### Type-spesific layer configs: |
91 | | - |
92 | | -`db` [`redis` - `gaurdian`] is the Redis DB number to be used. (Default:0) |
93 | | -`idle-timeout` [`redis` - `gaurdian`] is the timeout for idle connections to the Redis Server (see Redis documentation) (Default:0 - no timeout) |
94 | | -`address` [`redis` - `gaurdian`] is the Redis Server's Address (the master's address in case of a cluster) |
95 | | -`slaves` [`gaurdian`] is a **list** of Redis servers addresses pertaining to the slave nodes. |
96 | | -`max-memory` [`memory`] is the maximum amount of system memory which can be used by this particular layer. |
97 | | - |
98 | | - |
99 | 47 | ## Documentation |
100 | 48 |
|
101 | | -Documents are available at [https://godoc.org/github.com/cafebazaar/mnemosyne](https://godoc.org/github.com/cafebazaar/mnemosyne) |
102 | | - |
103 | | -## Built With |
104 | | - |
105 | | -* [Redis Go clinet](https://github.com/go-redis/redis) - Redis Client for Golang |
106 | | -* [BigCahce](https://github.com/allegro/bigcache) - An In-Memory cache library |
| 49 | +Documents are available at [https://godoc.org/git.cafebazaar.ir/bazaar/common/athena](https://godoc.org/git.cafebazaar.ir/bazaar/common/athena) |
107 | 50 |
|
108 | 51 | ## Contributing |
109 | 52 |
|
110 | | -Please read [CONTRIBUTING.md](https://github.com/cafebazaar/mnemosyne/blob/master/CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us. |
| 53 | +Please read [CONTRIBUTING.md](https://github.com/cafebazaar/athena/blob/master/CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us. |
111 | 54 |
|
112 | 55 | ## Versioning |
113 | 56 |
|
114 | | -We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/cafebazaar/mnemosyne/tags). |
| 57 | +We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/cafebazaar/athena/tags). |
115 | 58 |
|
116 | 59 | ## Roadmap |
117 | 60 | - Improve documentation |
118 | | - - Add tests |
| 61 | + - Add config checks |
119 | 62 |
|
120 | 63 | ## Authors |
121 | 64 |
|
122 | | -* **Ramtin Rostami** - *Initial work* - [rrostami](https://github.com/rrostami) |
123 | 65 | * **Pedram Teymoori** - *Initial work* - [pedramteymoori](https://github.com/pedramteymoori) |
124 | | -* **Parsa abdollahi** - *Initial work* - []() |
125 | 66 |
|
126 | | -See also the list of [contributors](https://github.com/cafebazaar/Mnemosyne/graphs/contributors) who participated in this project. |
| 67 | +See also the list of [contributors](https://github.com/cafebazaar/athena/graphs/contributors) who participated in this project. |
127 | 68 |
|
128 | 69 | ## License |
129 | 70 |
|
130 | 71 | This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details |
131 | 72 |
|
132 | 73 | ## Acknowledgments |
133 | 74 |
|
134 | | -* [Sepehr nematollahi](https://www.behance.net/sseeppeehhrr) Mnemosyne typography designer |
| 75 | +* [Sepehr nematollahi](https://www.behance.net/sseeppeehhrr) Athena typography designer |
135 | 76 |
|
136 | | -Made with <span class="heart">❤</span> in Cafebazaar search |
| 77 | +Made with <span class="heart">❤</span> in Cafebazaar search/ Cafebazaar discovery teams |
0 commit comments