Code Monkey home page Code Monkey logo

cloud_ndb_cache_collision_example's Introduction

Cloud NDB: Global Cache collision sample project (as of Sep. 8, 2021)

Installation

  1. install Datastore Emulator and related gcloud components
$ gcloud components install beta cloud-datastore-emulator app-engine-python app-engine-python-extras
  1. Create a python virtual environment
$ pipenv install
$ pipenv shell
  1. Install redis-server and launch it

Usage

  1. Launch the datastore emulator (in another terminal)
$ gcloud beta emulators datastore start
  1. Run the test server (The internal script will set environmental variables automatically)
$ pipenv run start
  1. Access to http://localhost:8000/ (at least twice).

Result example

The below result will be given if the redis cache and the datastore are empty.

In the first result, the IDs of the two samples are different(correct).

However, in the second and subsequent result, they have the same ID(wrong).

$ pipenv run start
INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
INFO:     Started parent process [34729]
INFO:     Started server process [34732]
INFO:     Started server process [34731]
INFO:     Waiting for application startup.
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Application startup complete.
sample1: 5761297639538688, sample2: 5704016969334784
INFO:     127.0.0.1:65521 - "GET / HTTP/1.1" 200 OK
sample1: 5761297639538688, sample2: 5761297639538688
INFO:     127.0.0.1:65521 - "GET / HTTP/1.1" 200 OK
sample1: 5761297639538688, sample2: 5761297639538688
INFO:     127.0.0.1:65522 - "GET / HTTP/1.1" 200 OK

cloud_ndb_cache_collision_example's People

Contributors

niccari avatar

Watchers

 avatar

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.