UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'Ib56+mtYtZt+4neZZWRqoGwOvb45xpxwB6b1Jwqggoc='
WHERE
key_id = 'd98f40551b4bd0a719dda796d3e4485833621a605c857b9ff9a74d1f329507d3'
AND (
token = 'Ib56+mtYtZt+4neZZWRqoGwOvb45xpxwB6b1Jwqggoc='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)