使用apollo客户端 3.查询了所有国家,想要从缓存中删除一个国家并重新渲染UI。
尝试如下;
onClick={() => {
cache.evict({ id: `Country:${country.code}` });
cache.gc();
}}
Run Code Online (Sandbox Code Playgroud)
但没有成功。如何驱逐一个国家?
使用 Apollo Client 3 和 eed 删除查询的所有结果,无论参数如何。像这样尝试过;
cache.evict({
id: "ROOT_QUERY",
fieldName: "countries"
});
cache.gc();
Run Code Online (Sandbox Code Playgroud)
然而,没有从缓存中删除任何内容,__APOLLO_CLIENT__.cache.data所有结果仍然在缓存中。另一方面,我可以删除单个Country对象。
你可以在这里看到它沙盒
创建了这个手风琴并将其用作菜单项。
但是,当我单击主标题时,手风琴摘要会垂直向下移动。
如何在打开时保持主瓷砖固定?
import React from "react";
import {
Typography,
Grid,
Accordion,
AccordionSummary,
AccordionDetails,
ListItem
} from "@material-ui/core";
import { createStyles, makeStyles, Theme } from "@material-ui/core/styles";
import ExpandMoreIcon from "@material-ui/icons/ExpandMore";
const useStyles = makeStyles((theme: Theme) =>
createStyles({
panelSummary: {
flexDirection: "row-reverse",
paddingLeft: "0px"
},
heading: {
fontSize: theme.typography.pxToRem(15),
fontWeight: theme.typography.fontWeightRegular
},
innerMenuItem: {
paddingLeft: "32px"
},
expanded: {
padding: "0px"
}
})
);
export default function App() {
const classes = useStyles();
return (
<Accordion>
<AccordionSummary
className={classes.panelSummary}
expandIcon={<ExpandMoreIcon />} …Run Code Online (Sandbox Code Playgroud) 使用 postgresql 10.6。我有一个名为place的表,其中包含城市的 jsonb 字段,其中包含一个 json 数组。我创造了杜松子酒指数。城市 json 数组将有数万条记录。我需要在 where 子句中查询该数组以获取 5000 个城市名称。该查询绝对应该使用 gin 索引来提高性能。正如我在执行计划中看到的那样,下面小提琴中的示例查询没有使用索引。应如何编写此查询以使用索引,使其运行速度更快。
表定义:
CREATE TABLE place (
cities jsonb NULL
);
CREATE INDEX "IX_place_cities" ON place USING gin (cities);
INSERT INTO place
(cities)
VALUES('[{"name": "paris", "continent": "europe"},
{"name": "london", "continent": "europe"},
{"name": "berlin", "continent": "europe"},
{"name": "istanbul", "continent": "europe"},
{"name": "prag", "continent": "europe"},
{"name": "rome", "continent": "europe"},
{"name": "wien", "continent": "europe"},
{"name": "tokyo", "continent": "asia"},
{"name": "beijing", "continent": "asia"},
{"name": "dakar", "continent": …Run Code Online (Sandbox Code Playgroud) 刚刚将我的 docker 映像部署到 Azure AKS 并创建了 nginx 入口控制器。我的图像具有 SSL 证书并自行处理 SSL。因此,我需要一条通往容器的直通路由。
当我导航到https://just-poc.live时 ,著名的 nginx 502 网关显示如下;
显然,nginx 找不到发送 https 流量的路由。
我应该怎么做才能让 nginx 控制器将流量路由到我的socket-poc部署?
nginx 入口控制器
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: hello-world-ingress
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/ssl-passthrough: "true"
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
rules:
- http:
paths:
- path: /(.*)
pathType: Prefix
backend:
service:
name: socket-poc
port:
number: 8081
Run Code Online (Sandbox Code Playgroud)
部署.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: socket-poc
spec:
replicas: 1
selector:
matchLabels:
app: socket-poc
template:
metadata:
labels: …Run Code Online (Sandbox Code Playgroud) reactjs ×3
graphql ×2
css ×1
jsonb ×1
kubernetes ×1
material-ui ×1
nginx ×1
postgresql ×1
ssl ×1