Are there any caching schemes for Delphi?

Question: What caching platforms are available for Delphi and how well are they developed? If not, then is there a generally accepted way to achieve the same goal? Applies to Delphi versions for targeting Win32.

Question: The type of framework that I request exists mainly within the framework of web development, allowing the user to:

  • Check cache for previously saved data / objects
  • Get data / object
  • Save new data / object
  • It is not necessary to tag Data / Object and tag it.
  • Exclude data / objects based on some criteria (tags, tags, time limits, etc.).

I understand that the absence of reflection services for Delphi objects without RTTI means that they probably will not exist exactly the same, but is there a similar way to achieve at least part of the same final result in a more Delphi method?

Alternative approach: As an alternative to the native Delphi library: Is there, for example, a good set of bindings for memcached or something like that?

+5
source share
6 answers

I used memcached on Linux (there are versions on Windows and MacOS, as well as almost any other OS), It is pretty simple.

I worked with it directly, using indy TIDTelnet, reading the protocol documentation , I used set , get , delete and exit .

I used the following commands (I installed and got a "name", 14 is the number of bytes to be saved):

osama@osama :~$ telnet 127.0.0.1 11211 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. set name 0 0 14 Osama Alassiry STORED get name VALUE name 0 14 Osama Alassiry END quit 

memcached allows you to store up to 1 MB per cache key, I used compound keys such as "Person | 17 | name", "Person | 17 | picture", "Employee | 7 | Salary | Basic" (these are dummy names unrelated to what I really did) ... I saved some binary files in the cache as base64, which allows using up to 768 thousand binary data.

memcached can also be distributed across multiple servers by hashing keys and selecting one of several hash-based servers.

+4
source

The Delphi client for Memcached can be found in google code:

http://code.google.com/p/delphimemcache/

+4
source

The caching mechanism needs manual rolling.

Splay Trees is a useful and simple mechanism for storing cached objects, as well as for determining how old they are.

+1
source

These frameworks provide some way to cache objects.

Depending on your exact requirements, they may be on top. If you try to implement your own solution, I would advise you to look at the various containers in Jedi VCL as a starting point.

+1
source

If you want to create your own, you probably want to do it in Freepascal, as it supports 64-bit support. Instead of binary splay trees, I would suggest k-ary.

+1
source

Ok I probably end up feeling stupid about this, but what's the problem with TStringList? I used a dynamic array of fairly structured data with a TStringList to find an item based on a row id. I recently upgraded TStringList to THashedStringList. It might be a little faster, but nothing really wonderful. The StringList / Array device provided excellent performance for my application.

I still cached from 100 to 150 records, but I expect it to work up to several thousand. In the business in which I work, this is a pretty big operation.

+1
source

Source: https://habr.com/ru/post/906110/


All Articles