Skip to content

Commit abbbdcc

Browse files
authored
Merge pull request #2815 from vibe-d/safe_redis
Make the Redis high-level APIs safe.
2 parents cacc2e5 + 09f8145 commit abbbdcc

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

CHANGELOG.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
Changelog
22
=========
33

4-
v0.10.2 - 2024-
4+
v0.10.2 - 2025-
55
--------------------
66

77
### Features and improvements ###
88

99
- Adds a new `@viaStatus` REST parameter annotation for customizing the HTTP status - [pull #2806][issue2806]
1010
- Adds a `MongoCollection.find` overload taking only a `FindOptions` parameter - [pull #2804][issue2804]
11+
- Made the whole Redis API `@safe` - [pull #2815][issue2815]
1112

1213
### Bug fixes ###
1314

14-
- Fixes parsing plural-only translations in PO files and improves error messages - [pull #2805][issue2805]
15+
- Fixed parsing plural-only translations in PO files and improves error messages - [pull #2805][issue2805]
1516

1617
[issue2804]: https://github.com/vibe-d/vibe.d/issues/2804
1718
[issue2805]: https://github.com/vibe-d/vibe.d/issues/2805
1819
[issue2806]: https://github.com/vibe-d/vibe.d/issues/2806
20+
[issue2815]: https://github.com/vibe-d/vibe.d/issues/2815
1921

2022

2123
v0.10.1 - 2024-09-07

redis/vibe/db/redis/idioms.d

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ struct RedisCollection(T /*: RedisValue*/, RedisCollectionOptions OPTIONS = Redi
8686
// TODO: add range queries
8787
}
8888

89-
int opApply(int delegate(long id) del)
89+
int opApply(int delegate(long id) @safe del)
9090
{
9191
static if (OPTIONS & RedisCollectionOptions.supportPaging) {
9292
foreach (id; m_db.zrange!long(m_allSet, 0, -1))
@@ -100,7 +100,7 @@ struct RedisCollection(T /*: RedisValue*/, RedisCollectionOptions OPTIONS = Redi
100100
return 0;
101101
}
102102

103-
int opApply(int delegate(long id, T) del)
103+
int opApply(int delegate(long id, T) @safe del)
104104
{
105105
static if (OPTIONS & RedisCollectionOptions.supportPaging) {
106106
foreach (id; m_db.zrange!long(m_allSet, 0, -1))

redis/vibe/db/redis/types.d

+5-4
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ struct RedisValue {
189189
string m_key;
190190
}
191191

192+
@safe:
192193
this(RedisDatabase db, string key) { m_db = db; m_key = key; }
193194

194195
/** The database in which the key is stored.
@@ -394,7 +395,7 @@ struct RedisHash(T = string) {
394395
void opIndexOpAssign(string op)(T value, string field) if (op == "+") { m_db.hincr(m_key, field, value); }
395396
void opIndexOpAssign(string op)(T value, string field) if (op == "-") { m_db.hincr(m_key, field, -value); }
396397

397-
int opApply(scope int delegate(string key, T value) del)
398+
int opApply(scope int delegate(string key, T value) @safe del)
398399
{
399400
auto reply = m_db.hgetAll(m_key);
400401
while (reply.hasNext()) {
@@ -407,7 +408,7 @@ struct RedisHash(T = string) {
407408
}
408409

409410

410-
int opApply(scope int delegate(string key) del)
411+
int opApply(scope int delegate(string key) @safe del)
411412
{
412413
auto reply = m_db.hkeys(m_key);
413414
while (reply.hasNext()) {
@@ -525,7 +526,7 @@ struct RedisList(T = string) {
525526
Dollar opSub(long off) { return Dollar(offset - off); }
526527
}
527528

528-
int opApply(scope int delegate(T) del)
529+
int opApply(scope int delegate(T) @safe del)
529530
{
530531
foreach (v; this[0 .. $])
531532
if (auto ret = del(v))
@@ -563,7 +564,7 @@ struct RedisSet(T = string) {
563564
//long sinterStore(string destination, string[] keys...) { return request!long("SINTERSTORE", destination, keys); }
564565
bool contains(T value) { return m_db.sisMember(m_key, value.toRedis()); }
565566

566-
int opApply(scope int delegate(T value) del)
567+
int opApply(scope int delegate(T value) @safe del)
567568
{
568569
foreach (m; m_db.smembers!string(m_key))
569570
if (auto ret = del(m.fromRedis!T()))

0 commit comments

Comments
 (0)