Code Monkey home page Code Monkey logo

redis-astra's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

redis-astra's Issues

The correct way to use pk

Hello, I have a question about the pk arguments.In my understanding, pk means the line of the table. If the developer create the model with the same pk, then the last one will be active and the old one will be covered. So, the developer will remember what's the current pk.
Currently, I use different global variables to save the pk for the different modules. It is not convenient and after program restart, the value will miss. So I will store it into redis later.

Do you have any idea about the correct way to pk ?
The following is the code.

`
devices_orm = DevicesModel(pk=1)
devices_orm_pk = 0
models_orm_pk = 0

def insert_redis(device):
global devices_orm
global devices_orm_pk
global models_orm_pk
devices_orm_pk = devices_orm_pk + 1
device_obj = DeviceModel(pk=devices_orm_pk)
device_obj.device_id = device["device_id"]

for model_object in device["models"]:
    models_orm_pk = 1 + models_orm_pk
    device_obj.models_list.lpush(
        MachineLearningModel(pk=models_orm_pk, name=model_object["name"], version=model_object["version"],
                             status=model_object["status"]))
devices_orm.devices_list.lpush(device_obj)

`

About hash cache

Object data from the local cache is inconsistent

for example

class SiteObject(models.Model):
    name = models.CharHash()

site1 = SiteObject(pk="site_pk_1")
site2 = SiteObject(pk="site_pk_1")
site1.name="pig"
print(site1.name)
site1.name = "cat"
print(site1.name)
print(site2.name)
site2.name="dog"
print(site2.name)
print(site1.name)

output

pig
cat
cat
dog
cat

As shown above, when site1.name is called, the data in redis is retrieved and stored in the site1 self._astra_hash object, so is site2, Therefore, the query of site1 will not be affected after the change of site2

Redis is so fast, I think the design might need to be rethought

redis-orm very nice

I think this is a very good project and I hope more and more people will know about it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.