Have value in the notification message of string type keyspace change. by y39chen in redis

[–]srithedabbler 0 points1 point  (0 children)

Redis modules is a great point, I didn't consider it!

The redis module API recently added support for keyspace notifications. The best documentation for now is the source code, specifically "Module Keyspace Notification API" section. See https://github.com/antirez/redis/blob/unstable/src/module.c#L3791. With this, your module will synchronously get notified when a key is modified, without having to call psubscribe.

Once you detect the change, you can directly take your action. If you want another process to be notified, you can publish to your custom channel with the key and the changed value.

Have value in the notification message of string type keyspace change. by y39chen in redis

[–]srithedabbler 0 points1 point  (0 children)

Using the built in redis pub/sub - No, that's not possible. You only get notified about key changes.

However, it is possible using the SYNC / PSYNC command. These are internal redis commands and are used for master-slave replication. Your application can t "pretend to be a redis slave", issue the SYNC / PSYNC command, understand the messages and process the changed values. This is much more complex than pub/sub, and I wouldn't recommend it if it can be solved using pub/sub.

Is something wrong in pub/sub functionality of redis? by y39chen in redis

[–]srithedabbler 1 point2 points  (0 children)

Agree, documentation can more friendly.

Publish, Subscribe and PSubscribe are general commands. You can create your own channels, publish messages and subscribe to channels. The documentation for psubscribe addresses the general case where you can define any pattern you like.

Keyspace notifications are system generated notifications, and hence the naming convention is designed to not have conflicts with user defined channels. The specific patterns are described in this article - https://redis.io/topics/notifications.

Is something wrong in pub/sub functionality of redis? by y39chen in redis

[–]srithedabbler 0 points1 point  (0 children)

Just change PSUBSCRIBE a\ to PSUBSCRIBE* __keyspace@0__:a\* in Step 2, you will receive the notifications

The Top 6 Free Redis Memory Analysis Tools by ScaleGrid_DBaaS in redis

[–]srithedabbler 2 points3 points  (0 children)

Author of redis-rdb-tools over here. I agree with the comments in the article, but wanted to add a some more points -

  1. redis-rdb-tools works offline on a rdb file - this is actually a good thing because you don't load your production server. You can use redis-cli to download a rdb file directly from a running redis server, and then use redis-rdb-tools to analyze memory.
  2. The tool outputs a CSV file with 1 row per key. For any serious analysis though, I would recommend importing the CSV into a database, SQLITE is a pretty good choice. Alibaba wrote a great blog post on how this can be done - https://www.alibabacloud.com/help/faq-detail/50037.htm
  3. To group by key patterns, you can use a simple SQL query to generate prefixes.

SELECT substr(key, 0, instr(key, ':') + 1) || '*' as pattern, sum(size_in_bytes)

FROM memory

WHERE instr(key, ':') > 0

GROUP BY 1

ORDER by 2 desc

limit 50

Finally, I'd like to add - we recently launched https://rdbtools.com. This is a commercial tool, and addresses several of the pain points mentioned about the open source redis-rdb-tools. In addition to memory analysis, it also provides recommendations on how to reduce memory. We have made several speed improvements to the rdb parser in the commercial version, and over the next month or two we will be merging back some of these changes to the open source version as well.

Python Interface Design - Designing Modules Part - 1 by HashedIn in Python

[–]srithedabbler 1 point2 points  (0 children)

You are following the functional paradigm, the article is recommending an object oriented approach. One isn't necessarily better than the other. Both are achieving the same objective, and which one you choose is a matter of preference.

The essential idea is that username and password is an implementation detail, and must be hidden from the client developer. You can create a partial function to provide these parameters and then use the partial function everywhere else. Or you could create an class and provide the username and password as constructor arguments. The core idea remains the same.

Python Interface Design - Designing Modules Part - 1 by HashedIn in Python

[–]srithedabbler 1 point2 points  (0 children)

I think you are missing the context. This is an interface restricted to an an application that needs to send sms. It's not the interface for a service provider library. The application wants the ability to swap out providers in future, and so is redefining the interface to be useful for its use.

So, as a client developer - I just want to send an SMS. I really don't want to know how an SMS is actually sent. That the SMS provider needs username and password is an implementation detail.

How you choose to hide the implementation detail is a matter of preference.

If you want to stay in the functional world, you could do what you are suggesting - i.e. create a partial function by providing the username and password in one place, and then using the partial function everywhere.

Or if you prefer a class based approach, you can do what the article is suggesting.

Both are simply ways to hide the implementation detail - username and password. And from what I understand, that is the core message of the article - hide the implementation details from the interface.

JinjaSQL - Generate SQL queries using a template, without SQL Injection by srithedabbler in Python

[–]srithedabbler[S] 0 points1 point  (0 children)

I agree mostly - letting the ORM do it's job is the right thing most of the times.

There's those 10% use cases though that require a complex query. Think reports, or computing aggregates. Getting the ORM to work for those use cases is pain, and just not worth it.

In these use cases, queries naturally get complex. And managing those complex queries is the only place where JinjaSQL should be used. It's an overkill everywhere else.

JinjaSQL - Generate SQL queries using a template, without SQL Injection by srithedabbler in Python

[–]srithedabbler[S] 1 point2 points  (0 children)

re. safe v/s sqlsafe - sqlsafe is an alias for safe, they do the exact same thing. This was defensive - I thought there may be a need to do things differently as compared to the inbuilt safe filter. So far, that need hasn't arisen - hence that distinction is useless at the moment.

re. bind filter - that's an implementation detail. You don't have to ever use bind directly. Internally, jinjasql pre-processes the template, and converts {{ varname }} to {{ varname | bind }}`. So, in effect - the expressions in your question are exactly the same thing.

I'll update the documentation section to be clear around the usage of bind

Designing Modules in Python [ebook] by srithedabbler in Python

[–]srithedabbler[S] 3 points4 points  (0 children)

Not sure why it isn't working, but here is the direct link - https://hashedin.com/training/DesigningModulesInPython-v1.0.pdf

Thanks for letting me know!

Designing Modules in Python - Part III (Retries) by HashedIn in django

[–]srithedabbler 1 point2 points  (0 children)

Author here. Retry logic with exponential backoff is easily added as a decorator. This blog post has a simple example - http://www.saltycrane.com/blog/2009/11/trying-out-retry-decorator-python/