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