Skip to content

Instantly share code, notes, and snippets.

@bnayae
bnayae / Deploy REDIS Modules (focus).cmd
Created December 30, 2021 10:54
Deploy REDIS + Modules (focus)
--set image.repository=redislabs/rejson \
--set image.tag=2.0.6 \
--set master.extraFlags='{--loadmodule,/usr/lib/redis/modules/redisearch.so,--loadmodule,/usr/lib/redis/modules/rejson.so}' \
--set replica.extraFlags='{--loadmodule,/usr/lib/redis/modules/redisearch.so,--loadmodule,/usr/lib/redis/modules/rejson.so}'
@bnayae
bnayae / Deploy REDIS Modules.cmd
Created December 30, 2021 10:14
Deploy REDIS OSS with JSON + Search module into your K8s cluster
helm upgrade NAME_OF_DEPLOYMENT bitnami/redis \
-i --wait --timeout 600s \
-n NAMESPACE \
--set metrics.enabled=true \
--set metrics.serviceMonitor.enabled=true \
--set metrics.serviceMonitor.namespace=monitoring \
--set usePassword={true/false} \
--set architecture=replication \
--set auth.enabled={true/false} \
--set image.repository=redislabs/rejson \
import React from 'react';
import { useRecoilState } from 'recoil';
import { stateComment, stateStars } from '../../../states';
import { StarsPicker } from '../../ui-units';
export const Details = () => {
const { id, journey } = useRoutingInfo(); // parse query string
const key: IRecoilId = { id, journey };
// best practice (won't cause rendering of the entire component)
const starState = stateStars(key);
// bad practice (will cause rendering of the entire component)
import { RecoilState } from 'recoil';
export interface IStarsPickerProps {
state: RecoilState<number>;
}
export const StarsPicker =({ state }: IStarsPickerProps) => {
const [value, setValue] = useRecoilState(state);
return (
<ReactStars
name="raring"
value={value}
if (guardRecoilDefaultValue(value)) {
reset(stateProductId(familyKey));
reset(stateColor(familyKey));
reset(stateSize(familyKey));
reset(stateCount(familyKey));
// remove from tracking
set(stateTracking(journey),
(prv) => [...prv.filter((m) => m !== id)]);
return; // no need for further handling
}
set(stateProductId(familyKey), value.productId);
set(stateColor(familyKey), value.color);
set(stateSize(familyKey), value.size);
set(stateCount(familyKey), value.count);
// track
set(stateTracking(journey), (prv) => {
return [...prv, id];
});
if (guardRecoilDefaultValue(value)) {
reset(stateProductId(familyKey));
reset(stateColor(familyKey));
reset(stateSize(familyKey));
reset(stateCount(familyKey));
// remove from tracking
set(stateTracking(journey),
(prv) => [...prv.filter((m) => m !== id)]);
return; // no need for further handling
}
import { DefaultValue } from 'recoil';
export const guardRecoilDefaultValue = (
candidate: any
): candidate is DefaultValue => {
if (candidate instanceof DefaultValue) return true;
return false;
};
const key: IRecoilId = {
id,
journey,
};
const order = useRecoilValue(stateOrder(key));
export const stateOrder = selectorFamily<IOrder, IRecoilId>({
key: 'state-order',
get: (familyKey) => ({ get }) => {
const { color, size, productId, count } = get(
waitForAll({
productId: stateProductId(familyKey),
color: stateColor(familyKey),
size: stateSize(familyKey),
count: stateCount(familyKey),
})