File tree 4 files changed +17
-1
lines changed
4 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 2
2
.bundle
3
3
Gemfile.lock
4
4
coverage /
5
+ .byebug_history
Original file line number Diff line number Diff line change @@ -77,6 +77,16 @@ Stasche.set(user_emails: User.where(id: ids).pluck(:email))
77
77
user_emails = Stasche .get(:user_emails )
78
78
```
79
79
80
+ ### Setting options
81
+ The set method allows you to add an ` options ` hash as a second parameter, for example to set a given key even if already exists
82
+ ``` rb
83
+ # Session A
84
+ Stasche .set({foo: ' bar' }, force: true )
85
+
86
+ # Session B
87
+ foo_value = Stasche .get(:foo )
88
+ ```
89
+
80
90
### Pushing/Peeking/Popping values
81
91
82
92
``` rb
Original file line number Diff line number Diff line change @@ -4,7 +4,8 @@ class KeyAlreadyExistsError < StandardError
4
4
5
5
def initialize ( key )
6
6
super (
7
- "Key #{ key } already set in stasche. Use `force: true` to override."
7
+ "Key #{ key } already set in stasche. Use `force: true` to override.\n " \
8
+ "Example: Stasche.set({foo: 'bar'}, force: true)"
8
9
)
9
10
end
10
11
Original file line number Diff line number Diff line change 74
74
error_class = Stasche ::Store ::KeyAlreadyExistsError
75
75
expect { client . set ( foo : 'bar' ) } . to raise_error ( error_class )
76
76
end
77
+
78
+ it 'does not throws an exception if forced' do
79
+ expect { client . set ( { foo : 'bar' } , force : true ) } . to_not raise_error
80
+ end
77
81
end
78
82
end
79
83
You can’t perform that action at this time.
0 commit comments