小编Tam*_*mas的帖子

搜索redis数据库的值

我是使用Redis DB的新手.在阅读了一些文档并查看了互联网上的一些示例以及扫描stackoverflow.com之后,我可以看到Redis速度非常快,扩展性很好,但这需要我们考虑我们的数据将如何定价的代价.在设计时访问它们以及它们将要经历的操作.我可以理解这一点,但我对使用普通的旧SQL在数据中搜索什么是如此简单,无论多么缓慢感到困惑.我可以用KEY命令以一种方式完成它,但它是O(N)操作而不是O(log(N)).所以我会失去Redis的一个优点.

有经验的同事在这说什么?

让我们举个例子:我们需要存储大约的个人数据.需要按姓名,电话号码搜索100.000人和这些数据.

为此,我将使用以下结构:

1. SET for storing all persons' ids {id1, id2, ...} 
2. HASH for each person to store personal data and name it 
like map:<id> e.g. map:id1{name:<name>, phone:<number>, etc...}
Run Code Online (Sandbox Code Playgroud)

解决方案1:

1. HASH for storing all persons' ids but the key should be the phone number
2. Then with the command KEY 123* all ids could be retrieved who have a phone number 
sarting with 123. On basis of the ids also the other personal data could …
Run Code Online (Sandbox Code Playgroud)

redis

18
推荐指数
3
解决办法
4万
查看次数

Java EE声明性安全性,无法为JDBC领域用户加载组

这是我在这里的第一篇文章.关于声明性Java EE安全性,我有两个问题:(1)基于文件的身份验证和(2)基于数据库的身份验证.我为这两个问题附上了配置的相关部分.我在Glassfish 3.1.1上运行代码.也提前感谢您的帮助.

我也在寻找我的问题的答案,并找到了一些有用的例子,我也把它放在信息的底部.我试图跟随它们,所以配置的当前状态可以包含这些样本的详细信息,但它们没有解决问题.

- 如果勾选了"默认主体到角色映射",则基于文件的身份验证可以正常工作,否则即使将主体添加到映射中它也不起作用.我可能没有以正确的方式配置某些东西.

基于-DB的身份验证.就授权而言,它无法正常工作,因为无法读取组名.详情见下文.身份验证可以正常工作,即用户被识别.我甚至尝试重命名表格以避免与Glassfish的一些内部内容发生潜在的名称冲突......

(1)基于文件的身份验证: 文件领域,2个用户:用户,管理员添加并分配给组:用户和管理员(配置/ server-config/security/realms /文件 - >管理用户)

配置/ server-config/security默认主体到角色映射"勾选" - >它的工作默认主体到角色映射"未勾选" - >即使将其添加到安全性映射,它也不起作用.

web.xml

[...]
    <security-constraint>
        <display-name>Admin Pages</display-name>
        <web-resource-collection>
            <web-resource-name>Protected Admin Area</web-resource-name>
            <description/>
            <url-pattern>/faces/admin/*</url-pattern>
            <http-method>GET</http-method>
            <http-method>POST</http-method>
            <http-method>HEAD</http-method>
            <http-method>PUT</http-method>
            <http-method>OPTIONS</http-method>
            <http-method>TRACE</http-method>
            <http-method>DELETE</http-method>
        </web-resource-collection>
        <auth-constraint>
            <description/>
            <role-name>admin</role-name>
        </auth-constraint>
    </security-constraint>
    <security-constraint>
        <display-name>User Pages</display-name>
        <web-resource-collection>
            <web-resource-name>Protected Users Area</web-resource-name>
            <description/>
            <url-pattern>/faces/users/*</url-pattern>
            <http-method>GET</http-method>
            <http-method>POST</http-method>
            <http-method>HEAD</http-method>
            <http-method>PUT</http-method>
            <http-method>OPTIONS</http-method>
            <http-method>TRACE</http-method>
            <http-method>DELETE</http-method>
        </web-resource-collection>
        <auth-constraint>
            <description/>
            <role-name>user</role-name>
        </auth-constraint>
    </security-constraint>
    <login-config>  
        <auth-method>FORM</auth-method>
        <realm-name>file</realm-name>
        <form-login-config>
            <form-login-page>/faces/loginForm.xhtml</form-login-page>
            <form-error-page>/faces/loginError.xhtml</form-error-page>
        </form-login-config>
    </login-config>

[...]
Run Code Online (Sandbox Code Playgroud)
glassfish-web.xml:

<glassfish-web-app>
    <security-role-mapping>
        <role-name>admin</role-name>
        <group-name>admin</group-name>
    </security-role-mapping> …
Run Code Online (Sandbox Code Playgroud)

java-ee declarative-security jdbcrealm

6
推荐指数
1
解决办法
3210
查看次数

标签 统计

declarative-security ×1

java-ee ×1

jdbcrealm ×1

redis ×1