UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'jbBRYa8ftDUzXOBPK8sEKTvkDDFgwoZLQnIUBtr2gss='
WHERE
key_id = 'd242b6461ef4561528edb2a9fdae9a1487205e7935394a19933b37fe1c40fa60'
AND (
token = 'jbBRYa8ftDUzXOBPK8sEKTvkDDFgwoZLQnIUBtr2gss='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)