Code Monkey home page Code Monkey logo

o11n-plugin-cache's Introduction

Cache plug-in for vRealize Orchestrator

The Cache plug-in for vRealize Orchestrator is a a plug-in which provides distributed in-memory data structures such as maps, queues sets etc.

Basic features of the plug-in:

  • Distributed in-memory data structures with TTL/lease options
  • Distributed unique ID generation
  • Distributed locking
  • Automatic auto-discovery with other vRO nodes which belong to the cluster

Plugin download

o11nplugin-cache-1.0.0.vmoapp

Supported platform version

The Cache plug-in supports vRO 6.0 and later.

Sample scripting

#####Using lists:

//Add a value in the default list
CacheManager.listService.add("my-value");

//Get the first value from the list
var value = CacheManager.listService.get(0);

//Clear the default list
CacheManager.listService.clear();

#####Using sets:

//Add a value in the default set
CacheManager.setService.add("my-value");

//Get the elements from the default set
var elements = CacheManager.setService.elements();

//Clear the default set
CacheManager.setService.clear();

#####Using maps:

//Put a value in the default map without TTL
CacheManager.mapService.put("my-key", "my-value");

//Put a value in the default map with a TTL of 2 minutes
CacheManager.mapService.put("my-key", "my-other-value", 2, CacheTimeUnit.MINUTES);

//Get the value from the map
var value = CacheManager.mapService.get("my-key");

#####Using queues:

//Offer a value in the default queue, waiting up to 2 minutes if necessary for space to become available
CacheManager.queueService.offer("my-value", 2, CacheTimeUnit.MINUTES);

//Offer a value in the default queue, waiting if necessary for space to become available
CacheManager.queueService.offer("my-value");

//Poll a value from the default queue
var value = CacheManager.queueService.poll();

//Put a value from the default queue, waiting if necessary for space to become available
CacheManager.queueService.put("my-value");

//Retrieve and remove the head of the queue. Throws an exception if queue is empty
val value = CacheManager.queueService.remove();

#####Using ring buffers:

//Adds an item to the tail of the ringbuffer 
CacheManager.ringbufferService.add("my-value");
//Get the sequence of the head
var sequence = CacheManager.ringbufferService.headSequence();
while(true){
    //Reads the item from the ringbuffer
    var item = CacheManager.ringbufferService.readOne(sequence);
    sequence++;
}

#####Using ID generators:

//Create a unique ID with the default generator
var id = IdGeneratorManager.idGeneratorService.newId();

//Create a unique ID with a named ID generator
var id = IdGeneratorManager.idGeneratorService.newIdForGenerator("my-id-generator");

#####Using locks:

//Acquires a lock by current workflow token id for 2 minutes
LockManager.lockService.lock(workflow.id, 2, CacheTimeUnit.MINUTES);

//Releases the lock. Will fail if invoked from another workflow
LockManager.lockService.unlock(workflow.id);

//Tries to acquire a lock if it is free within 10 seconds. Returns true if succeeded
var result = LockManager.lockService.tryLock(workflow.id, 10, CacheTimeUnit.SECONDS);

//Tries to acquire a lock for 2 minutes, if it is free within 10 seconds. Returns true if succeeded
var resut = LockManager.lockService.tryLockWithLease(workflow.id, 10, CacheTimeUnit.SECONDS, 2, CacheTimeUnit.MINUTES);

Dependencies

The Cache plug-in for vRO uses the following third-party libraries:

  • Hazelcast - an in-memory data grid middleware, distributed under the Apache License, Version 2.0.
  • Google Guava - core libraries for Java-based projects, distributed under the Apache License, Version 2.0

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.