UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = '8nRDmYAw6IZDXm3gbn4MvRXPgViNVCSpsWjJ313f+4k='
WHERE
key_id = 'a2d5d9fed1e0bd6360590e4bf8b83ee21edb7c6c44a750f05e9b715614792f3a'
AND (
token = '8nRDmYAw6IZDXm3gbn4MvRXPgViNVCSpsWjJ313f+4k='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)